/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.imenu.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Yunzi
 */
@Entity
@Table(name = "imenu_store")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ImenuStore.findAll", query = "SELECT i FROM ImenuStore i"),
    @NamedQuery(name = "ImenuStore.findById", query = "SELECT i FROM ImenuStore i WHERE i.id = :id"),
    @NamedQuery(name = "ImenuStore.findByParentId", query = "SELECT i FROM ImenuStore i WHERE i.parentId = :parentId"),
    @NamedQuery(name = "ImenuStore.findByBrandName", query = "SELECT i FROM ImenuStore i WHERE i.brandName = :brandName"),
    @NamedQuery(name = "ImenuStore.findByStoreName", query = "SELECT i FROM ImenuStore i WHERE i.storeName = :storeName"),
    @NamedQuery(name = "ImenuStore.findByAddress", query = "SELECT i FROM ImenuStore i WHERE i.address = :address"),
    @NamedQuery(name = "ImenuStore.findByTerminalId", query = "SELECT i FROM ImenuStore i WHERE i.terminalId = :terminalId"),
    @NamedQuery(name = "ImenuStore.findByTel", query = "SELECT i FROM ImenuStore i WHERE i.tel = :tel"),
    @NamedQuery(name = "ImenuStore.findByCreateTime", query = "SELECT i FROM ImenuStore i WHERE i.createTime = :createTime")})
public class ImenuStore implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id", insertable=false)
    private Integer id;
    @Column(name = "parent_id")
    private Integer parentId;
    @Size(max = 255)
    @Column(name = "brand_name")
    private String brandName;
    @Size(max = 255)
    @Column(name = "store_name")
    private String storeName;
    @Size(max = 255)
    @Column(name = "address")
    private String address;
    @Size(max = 255)
    @Column(name = "terminalId")
    private String terminalId;
    @Size(max = 255)
    @Column(name = "tel")
    private String tel;
    @Column(name = "create_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
        @OneToMany(mappedBy = "store")
    private Collection<ImenuUser> imenuUserCollection;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "store")
    private Collection<ImenuMenu> imenuMenuCollection;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "storeId")
    private Collection<ImenuTag> imenuTagCollection;
    
    public ImenuStore() {
    }

    public ImenuStore(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getParentId() {
        return parentId;
    }

    public String getTerminalId() {
        return terminalId;
    }

    public void setTerminalId(String terminalId) {
        this.terminalId = terminalId;
    }

    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }

    public String getBrandName() {
        return brandName;
    }

    public void setBrandName(String brandName) {
        this.brandName = brandName;
    }

    public String getStoreName() {
        return storeName;
    }

    public void setStoreName(String storeName) {
        this.storeName = storeName;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @XmlTransient
    public Collection<ImenuUser> getImenuUserCollection() {
        return imenuUserCollection;
    }

    public void setImenuUserCollection(Collection<ImenuUser> imenuUserCollection) {
        this.imenuUserCollection = imenuUserCollection;
    }

    @XmlTransient
    public Collection<ImenuMenu> getImenuMenuCollection() {
        return imenuMenuCollection;
    }

    public void setImenuMenuCollection(Collection<ImenuMenu> imenuMenuCollection) {
        this.imenuMenuCollection = imenuMenuCollection;
    }

    @XmlTransient
    public Collection<ImenuTag> getImenuTagCollection() {
        return imenuTagCollection;
    }

    

    public void setImenuTagCollection(Collection<ImenuTag> imenuTagCollection) {
        this.imenuTagCollection = imenuTagCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ImenuStore)) {
            return false;
        }
        ImenuStore other = (ImenuStore) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.imenu.entity.ImenuStore[ id=" + id + " ]";
    }
}
